package map;

import java.util.HashSet;
import java.util.List;
import java.util.Set;

public class DestinationCity1436 {
    public String destCity(List<List<String>> paths) {
        if(paths.size()==0){
            return "";
        }
        Set<String> set = new HashSet<>();
        Set<String> begin = new HashSet<>();
        for (int i = 0; i < paths.size(); i++) {
            List<String> path = paths.get(i);
            set.add(path.get(0));
            set.add(path.get(1));
            begin.add(path.get(0));
        }

        for (String s :set
                ) {
            if(!begin.contains(s)){
                return s;
            }
        }
        return "";
    }
}
